package vip.liux.front.application.service.product;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import vip.liux.contracts.infrastructure.automap.IgnoreAudited;
import vip.liux.contracts.infrastructure.automap.MapMapper;
import vip.liux.contracts.infrastructure.automap.MapStructConfig;
import vip.liux.contracts.models.product.Category;
import vip.liux.contracts.models.product.Product;

@Mapper(config = MapStructConfig.class, uses = {MapMapper.class})
public interface AutoMapperProfile {

    AutoMapperProfile INSTANCE = Mappers.getMapper(AutoMapperProfile.class);

    @IgnoreAudited
    @Mapping(target = "parent", ignore = true)
    @Mapping(target = "children", ignore = true)
    CategoryDto toDto(Category category);


    @Mapping(target = "image", ignore = true)
    @Mapping(target = "salePrice", ignore = true)
    @Mapping(target = "goodsCode", source = "spu")
    @Mapping(target = "goodsName", source = "productName")
    GoodsDto toGoodsDto(Product product);
}
